#!/usr/bin/env python
# encoding: utf-8
"""
draw.py

Created by Morgan Quirk on 2007-08-09.
"""

import pygame

class Draw:
    """Used to draw everything on the screen, every frame"""
    def __init__(self, window):
        self.window = window
        self.screen = pygame.display.set_mode((self.window.width, self.window.height))
        
    def draw_scene(self, background, ent, ui):
        """Runs the three draw functions and updates the screen"""
        self.draw_background(background)
        self.draw_entities(ent)
        self.draw_ui(ui)
        pygame.display.update()
        
    def draw_background(self, background):
        """Draws the background image"""
        self.screen.fill((255,255,255))
        
    def draw_entities(self, ent):
        """Draws every entity"""
        for entity in ent:
            img, rect = entity.get_image()
            if img is not None:
                if self.window.is_on_screen(rect):
                    self.screen.blit(img, (rect[0]-self.window.x1, rect[1]-self.window.y1))
        
    def draw_ui(self, ui):
        """Draws ui"""
        pass